/**Increasing order**/
public class BinarySearch 
{
	Comparable[] arr;
	int n;
	
	public BinarySearch(Comparable[] arr)
	{
		this.arr = arr;
	}
	
	public int search(Comparable key)
	{
		int b = arr.length - 1;
		int a = 0;
		n = 0;
		
		while(arr[(b+a)/2].compareTo(key) != 0)
		{
			n++;
			if(b <= a)
				break;
			if(arr[(b+a)/2].compareTo(key) < 0)
			{
				a = (b+a)/2 + 1;
			}
			else
				if(arr[(b+a)/2].compareTo(key) > 0)
				{
					b = (b+a)/2;
				}
			
		}
		return n;
	}
}
